/*
  将两个数组交叉融合，生成一个新数组
  return 返回融合后的新数组,如果传入的参数均为空时返回null
*/
function fuseArray(arr1,arr2){
  let newArray = new Array();
  //两个数组均为空或数组元素均为0，返回null
  if((arr1==null || arr1.length==0) && (arr2==null || arr2.length==0)){
    return null;
  //arr1不为空，arr2为空或元素个数不为0时返回arr1
}else if(arr1 !=null && (arr2 == null || arr2.length == 0)){
      return arr1;
  //arr1为空或元素个数为0，arr2不为空时返回arr2
  }else if((arr1 == null || arr1.length == 0) && arr2 != null){
      return arr2;
  }else{//arr1和arr2均不为空时进行融合处理
    let maxLen;
    arr1.length > arr2.length ? maxLen = arr1.length : maxLen = arr2.length;
    for(let i=0;i<maxLen;i++){
      if(i < arr1.length) {newArray.push(arr1[i]);}
      if(i < arr2.length){newArray.push(arr2[i]);}
    }
    return newArray;
  }
}
console.log(fuseArray(new Array("B","C"),null));
console.log(fuseArray(null,new Array("a","d")));
console.log(fuseArray(new Array("B","C"),new Array("a","d")));
console.log(fuseArray(new Array("B","C","D","E"),new Array("a","d")));
console.log(fuseArray(new Array("B","C"),new Array("a","b","c","d")));
